const express = require('express');
const myroute = express.Router()
const mySql = require('../utils/database')
// 接受前端数据

myroute.post('/addboard', function (request, response) {
    let iskong
    if (request.body.isnotname == 1) {
        iskong = '匿名'
    } else {
        iskong = `${request.body.b_name}`
    }
    const sql = `insert into board values(null,'${iskong}','${request.body.b_time}',default,'${request.body.b_con}')`
    mySql.query(sql, function (err, data) {
        console.log(err, data);
        if (err) {
            console.log(err);
            response.send({ error: 1, msg: err })
        } else {
            response.send({ error: 0, msg: '添加成功', data: data })
        }
    })

})
module.exports = myroute